Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a python distutils setup.py for easy installation as a python package #42

Merged
merged 2 commits into from
Jun 1, 2015

Conversation

PaulFurtado
Copy link
Contributor

This allows python developers to build jsonnet by running:

python setup.py build

And it can be installed to the system with something like:

sudo python setup.py install

It would be great to use this to automatically deploy to pypi with travis, so python users can get a working jsonnet by just running:

pip install jsonnet

This would also allow python applications to specify jsonnet as a dependency.

See: http://docs.travis-ci.com/user/deployment/pypi/

Let me know what you think

@sparkprime
Copy link
Contributor

Being able to install Jsonnet's python bindings with just pip install jsonnet sounds awesome.

Can we set it up so only stable releases get uploaded? I'll cut a new one right now, it's been a while.

@PaulFurtado
Copy link
Contributor Author

This setup.py is able to build fine, however my company's internal pypi server was rejecting it (returning 500 errors without an error message). I'm going to take a look and see if it's the setup.py's fault or the server's fault before we merge this.

As for telling travis to only upload stable builds to pypi, travis has an option for uploading to pypi for only tagged commits instead of all commits (however, this is still an issue if you tag commits which are unstable). I think their intention is that you would have a "stable" branch which only has stable tags on it. Note that it's also not all that inconvenient to upload to pypi manually - if you have a .pypirc, it's as easy as running one command.

@PaulFurtado
Copy link
Contributor Author

Just updated the PR with fixes that allow it to actually work with PyPi:

  • The package needed to be called "jsonnet" instead of "_jsonnet". That means you install it with "pip install jsonnet" but you still use it via "import _jsonnet"
  • Added a MANIFEST.in which puts the entire directory into the distribution - previously distutiles was only adding the files in JSONNET_SOURCES

I also added you as the author.
I tested this against a local pypi-server with all of the defaults.

@PaulFurtado
Copy link
Contributor Author

Also put a test version of it called "paul-jsonnet" into pypi to test that it works with the official pypi. You can try it out with:

pip install paul-jsonnet

@sparkprime
Copy link
Contributor

It worked for me, but I had to use --pre. Presumably this is because I appended -beta to all the versions. I did that because I misunderstood semantic versioning at the time :). If I do a new release with just v0.8.1 do you think it would fix it?

@dgarstang
Copy link

Doesn't work for me, on a Mac.

(venv2)[chef=prod] Douglass-MacBook-Pro:git doug$ pip install paul-jsonnet --pre
Downloading/unpacking paul-jsonnet
  Downloading paul-jsonnet-v0.6.0-beta.tar.gz (1.6MB): 1.6MB downloaded
  Running setup.py (path:/private/var/folders/qn/sdwwlm7s4zq7mg3535279h240000gn/T/pip_build_doug/paul-jsonnet/setup.py) egg_info for package paul-jsonnet

Installing collected packages: paul-jsonnet
  Running setup.py install for paul-jsonnet
    make: `std.jsonnet.h' is up to date.
    building '_jsonnet' extension
    cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c libjsonnet.cpp -o build/temp.macosx-10.9-intel-2.7/libjsonnet.o -std=c++0x
    cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c lexer.cpp -o build/temp.macosx-10.9-intel-2.7/lexer.o -std=c++0x
    cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c parser.cpp -o build/temp.macosx-10.9-intel-2.7/parser.o -std=c++0x
    cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c static_analysis.cpp -o build/temp.macosx-10.9-intel-2.7/static_analysis.o -std=c++0x
    cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c vm.cpp -o build/temp.macosx-10.9-intel-2.7/vm.o -std=c++0x
    vm.cpp:203:20: warning: implicit conversion loses integer precision: 'size_type' (aka 'unsigned long') to 'unsigned int' [-Wshorten-64-to-32]
                return stack.size();
                ~~~~~~ ^~~~~~~~~~~~
    vm.cpp:209:36: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
                for (int i=stack.size()-1 ; i>=0 ; --i) {
                         ~ ~~~~~~~~~~~~^~
    vm.cpp:301:36: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
                for (int i=stack.size()-1 ; i>=0 ; --i) {
                         ~ ~~~~~~~~~~~~^~
    vm.cpp:322:36: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
                for (int i=stack.size()-1 ; i>=0 ; --i) {
                         ~ ~~~~~~~~~~~~^~
    vm.cpp:360:30: warning: unused variable 'bind' [-Wunused-variable]
                for (const auto &bind : up_values) {
                                 ^
    vm.cpp:370:37: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
                for (int i=stack.size() - 1 ; i>=0 ; --i) {
                         ~ ~~~~~~~~~~~~~^~~
    vm.cpp:1419:54: warning: implicit conversion loses integer precision: 'const unsigned long' to 'unsigned int' [-Wshorten-64-to-32]
                                unsigned builtin = func->builtin;
                                         ~~~~~~~   ~~~~~~^~~~~~~
    7 warnings generated.
    vm.cpp:360:30: warning: unused variable 'bind' [-Wunused-variable]
                for (const auto &bind : up_values) {
                                 ^
    1 warning generated.
    cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _jsonnet.c -o build/temp.macosx-10.9-intel-2.7/_jsonnet.o -std=c++0x
    error: invalid argument '-std=c++0x' not allowed with 'C/ObjC'
    error: command 'cc' failed with exit status 1
    Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/private/var/folders/qn/sdwwlm7s4zq7mg3535279h240000gn/T/pip_build_doug/paul-jsonnet/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/qn/sdwwlm7s4zq7mg3535279h240000gn/T/pip-Egrdcg-record/install-record.txt --single-version-externally-managed --compile:
    running install

running build

make: `std.jsonnet.h' is up to date.

running build_ext

building '_jsonnet' extension

creating build

creating build/temp.macosx-10.9-intel-2.7

cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c libjsonnet.cpp -o build/temp.macosx-10.9-intel-2.7/libjsonnet.o -std=c++0x

cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c lexer.cpp -o build/temp.macosx-10.9-intel-2.7/lexer.o -std=c++0x

cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c parser.cpp -o build/temp.macosx-10.9-intel-2.7/parser.o -std=c++0x

cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c static_analysis.cpp -o build/temp.macosx-10.9-intel-2.7/static_analysis.o -std=c++0x

cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c vm.cpp -o build/temp.macosx-10.9-intel-2.7/vm.o -std=c++0x

vm.cpp:203:20: warning: implicit conversion loses integer precision: 'size_type' (aka 'unsigned long') to 'unsigned int' [-Wshorten-64-to-32]

            return stack.size();

            ~~~~~~ ^~~~~~~~~~~~

vm.cpp:209:36: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]

            for (int i=stack.size()-1 ; i>=0 ; --i) {

                     ~ ~~~~~~~~~~~~^~

vm.cpp:301:36: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]

            for (int i=stack.size()-1 ; i>=0 ; --i) {

                     ~ ~~~~~~~~~~~~^~

vm.cpp:322:36: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]

            for (int i=stack.size()-1 ; i>=0 ; --i) {

                     ~ ~~~~~~~~~~~~^~

vm.cpp:360:30: warning: unused variable 'bind' [-Wunused-variable]

            for (const auto &bind : up_values) {

                             ^

vm.cpp:370:37: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]

            for (int i=stack.size() - 1 ; i>=0 ; --i) {

                     ~ ~~~~~~~~~~~~~^~~

vm.cpp:1419:54: warning: implicit conversion loses integer precision: 'const unsigned long' to 'unsigned int' [-Wshorten-64-to-32]

                            unsigned builtin = func->builtin;

                                     ~~~~~~~   ~~~~~~^~~~~~~

7 warnings generated.

vm.cpp:360:30: warning: unused variable 'bind' [-Wunused-variable]

            for (const auto &bind : up_values) {

                             ^

1 warning generated.

cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _jsonnet.c -o build/temp.macosx-10.9-intel-2.7/_jsonnet.o -std=c++0x

error: invalid argument '-std=c++0x' not allowed with 'C/ObjC'

error: command 'cc' failed with exit status 1

----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/private/var/folders/qn/sdwwlm7s4zq7mg3535279h240000gn/T/pip_build_doug/paul-jsonnet/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/qn/sdwwlm7s4zq7mg3535279h240000gn/T/pip-Egrdcg-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /private/var/folders/qn/sdwwlm7s4zq7mg3535279h240000gn/T/pip_build_doug/paul-jsonnet
Storing debug log for failure in /var/folders/qn/sdwwlm7s4zq7mg3535279h240000gn/T/tmpPwS2Lf

@sparkprime
Copy link
Contributor

@PaulFurtado Sorry I forgot about this. I'm going to merge, but first I need you to sign the contributor license agreement, either https://cla.developers.google.com/about/google-individual or https://cla.developers.google.com/about/google-corporate -- it's a legal requirement from Google (common for big companies working in the open source community).

@sparkprime
Copy link
Contributor

@dgarstang Thanks for the report -- I'll try this out on latest HEAD and see if any issue remains. From a quick glance at the Makefile I can't see -std=c++0x being passed to $CC so I think it will work now.

@PaulFurtado
Copy link
Contributor Author

@sparkprime Sorry for the delay, I just submitted the CLA, thanks

@PaulFurtado
Copy link
Contributor Author

Yes, it fails to compile on OS X. My friend gave me his macbook for 20 minutes to debug it, but I couldn't figure out what compile flags I needed to make it work, even running make _jsonnet.so fails. I think the issue is that jsonnet links against python (which I believe is c99), but also uses c++11 and for some reason clang doesn't like mixing them. I think this issue is related: https://support.enthought.com/hc/en-us/articles/204469410-OS-X-GCC-Clang-and-Cython-in-10-9-Mavericks

@sparkprime
Copy link
Contributor

So I got my colleague to try make _jsonnet.so on his 10.9.5 mac and it worked OK.

sparkprime added a commit that referenced this pull request Jun 1, 2015
Added a python distutils setup.py for easy installation as a python package
@sparkprime sparkprime merged commit 9ba9654 into google:master Jun 1, 2015
@dgarstang
Copy link

David,

Thanks. Doesn't work for me tho...

cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os
-pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX
-DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv
-Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe
-I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7
-c _jsonnet.c -o build/temp.macosx-10.9-intel-2.7/_jsonnet.o -std=c++0x
error: invalid argument '-std=c++0x' not allowed with 'C/ObjC'
error: command 'cc' failed with exit status 1

Doug.

On Mon, Jun 1, 2015 at 12:42 PM, Dave Cunningham [email protected]
wrote:

Merged #42 #42.


Reply to this email directly or view it on GitHub
#42 (comment).

Regards,

Douglas Garstang
http://www.linkedin.com/in/garstang
Email: [email protected]
Cell: +1-805-340-5627

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants